<?php

/**
 * Brokinginquiry
 *
 * PHP version 5
 *
 * @category Model
 * @package  Croogo
 * @version  1.0
 * @author   Tran Van Dung <dungtv@ic-t.info>
 * @license  http://www.opensource.org/licenses/mit-license.php The MIT License
 * @link     http://www.croogo.org
 */
class Brokinginquiry extends AppModel {

    /**
     * Model name
     *
     * @var string
     * @access public
     */
    public $name = 'Brokinginquiry';
    /**
     * Behaviors used by the Model
     *
     * @var array
     * @access public
     */
    public $actsAs = array(
        'Encoder',
        'Url',
        'Cached' => array(
            'prefix' => array(
                'brokinginquiry_',
            ),
        ),
    );
    public $validate = array(
        'account_name' => array(
            'rule' => 'notEmpty',
            'message' => 'This field cannot be left blank.',
        ),
        'date_from' => array(
            'rule' => 'notEmpty',
            'message' => 'This field cannot be left blank.',
        ),
        'date_to' => array(
            'rule' => 'notEmpty',
            'message' => 'This field cannot be left blank.',
        ),
    );
    /**
     * Model associations: belongsTo
     *
     * @var array
     * @access public
     */
    public $belongsTo = array(
        'Aihcontact' => array(
            'className' => 'Aihcontact',
            'foreignKey' => 'inquirer_id',
            'conditions' => '',
            'fields' => '',
            'order' => '',
        )
    );
    
    public function lock($ids=array(), $tbl='cc_aihcontacts', $lock=1) { // $tbl='cc_markets' || $tbl='cc_insurancetypes'
        if($ids != null) {
            return $this->query("UPDATE `".$tbl."` AS `TBL` SET `TBL`.`lock`=`TBL`.`lock`+".$lock." WHERE `TBL`.`id` IN (".  implode(',', $ids).") ");
        } 
        return false;
    }
}

?>